import request from '@/utils/request'

/**
 * @description 获取漏洞验证环境列表
 * @param {Object} params - 查询参数
 * @returns {Promise} Promise 对象
 */
export function getVulnEnvironmentList(params) {
  return request({
    url: '/verify/env_info',
    method: 'get',
    params,
  })
}

/**
 * @description 获取漏洞验证环境详情
 * @param {string|number} id - 环境ID
 * @returns {Promise} Promise 对象
 */
export function getVulnEnvironmentDetail(id) {
  return request({
    url: `/verify/detail?id=${id}`,
    method: 'get'
  })
}

/**
 * @description 添加漏洞验证环境
 * @param {Object} data - 环境信息
 * @returns {Promise} Promise 对象
 */
export function addVulnEnvironment(data) {
  return request({
    url: '/api/vulnEnvironment/add',
    method: 'post',
    data
  })
}

/**
 * @description 更新漏洞验证环境
 * @param {Object} data - 环境信息
 * @returns {Promise} Promise 对象
 */
export function updateVulnEnvironment(data) {
  return request({
    url: '/api/vulnEnvironment/update',
    method: 'post',
    data
  })
}

/**
 * @description 删除漏洞验证环境
 * @param {string|number} id - 环境ID
 * @returns {Promise} Promise 对象
 */
export function deleteVulnEnvironment(id) {
  return request({
    url: `/api/vulnEnvironment/delete/${id}`,
    method: 'post'
  })
}

/**
 * @description 启动漏洞验证环境
 * @param {string|number} id - 环境ID
 * @returns {Promise} Promise 对象
 */
export function OperateVulnEnvironment(data) {
  return request({
    url: `/verify/operation/`,
    method: 'post',
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data
  })
}

/**
 * @description 停止漏洞验证环境
 * @param {string|number} id - 环境ID
 * @returns {Promise} Promise 对象
 */
export function stopVulnEnvironment(id) {
  return request({
    url: `/api/vulnEnvironment/stop/${id}`,
    method: 'post'
  })
}

/**
 * @description 获取漏洞验证环境状态
 * @param {string|number} id - 环境ID
 * @returns {Promise} Promise 对象
 */
export function getVulnEnvironmentStatus(id) {
  return request({
    url: `/api/vulnEnvironment/status/${id}`,
    method: 'get'
  })
}

/**
 * @description 获取漏洞验证任务监控数据
 * @param {string|number} taskId - 任务ID
 * @returns {Promise} Promise 对象
 */
export function getVulnVerificationMonitor(taskId) {
  return request({
    url: `/api/vulnEnvironment/monitor/${taskId}`,
    method: 'get'
  })
}

/**
 * @description 获取漏洞验证任务日志
 * @param {string|number} taskId - 任务ID
 * @returns {Promise} Promise 对象
 */
export function getVulnVerificationLogs(taskId) {
  return request({
    url: `/api/vulnEnvironment/logs/${taskId}`,
    method: 'get'
  })
}

/**
 * @description 保存环境配置
 * @param {Object} data - 配置信息
 * @returns {Promise} Promise 对象
 */
export function saveEnvironmentConfig(data) {
  return request({
    url: '/api/vulnEnvironment/config/save',
    method: 'post',
    data
  })
}

/**
 * @description 获取环境配置
 * @returns {Promise} Promise 对象
 */
export function getEnvironmentConfig() {
  return request({
    url: '/api/vulnEnvironment/config',
    method: 'get'
  })
} 